
$(function(){
  $(".collapse-link").click(function() {
    var o = $(this).closest("div.ibox"),
      e = $(this).find("i"),
      i = o.find("div.ibox-content");
    i.slideToggle(200),
      e.toggleClass("fa-chevron-up").toggleClass("fa-chevron-down"),
      o.toggleClass("").toggleClass("border-bottom"),
      setTimeout(function() {
          o.resize(),
            o.find("[id^=map-]").resize()
        },
        50);
  });
  //$("#grid tbody").delegate("input.grid","click",function(event){
  //  event.stopPropagation();
  //});

  $("#grid tbody tr").delegate("td","click",function(){
    if($(this).parent('tr').find('td').index($(this)) > 0){

      if($(this).parent('tr').find('input.grid').prop("checked")){
        $('input.grid').prop("checked",false);
        $('input.select-on-check-all').prop("checked",false);
        $(this).parent('tr').find('input.grid').prop("checked", false);
      }else{
        $('input.grid').prop("checked",false);
        $('input.select-on-check-all').prop("checked",false);
        $(this).parent('tr').find('input.grid').prop("checked", true);
      }
    }
  });


  $(".BX_action_null").click(function(){
    var url = $(this).data('href');
    var title = $(this).data('title');
    $bx.layer(url,title);
  });



  toastr.options = {
    "closeButton": true,
    "debug": false,
    "progressBar": true,
    "positionClass": "toast-top-right",
    "onclick": null,
    "showDuration": "500",
    "hideDuration": "2000",
    "timeOut": "5000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
  };


  $(".BX_action_id").click(function(){
    var id = $bx.getId();
    if(id == -1){
      toastr.error("请只选择一条数据");
    }else if(id == 0){
      toastr.error("请选择要操作的数据");
    }else{
      var url = $bx.toUrl($(this).data('href'),'id='+id);
      var title = $(this).data('title');
      $bx.layer(url,title);
    }
  });

  $(".BX_action_id_jump").click(function(){

    var id = $bx.getId();
    if(!id){
      toastr.error("请选择要操作的数据");
      return false;
    }
    window.location.href = $bx.toUrl($(this).data('href'),'id='+id);
  });


  $(".BX_action_ids").click(function(){
    var ids = $bx.getParamIds();
    console.log(ids);
    if(!ids){
      toastr.error("请选择要操作的数据",'测试');
      return false;
    }
    var url = $bx.toUrl($(this).data('href'),ids);
    var title = $(this).data('title');
    $bx.layer(url,title);
  });

  $(".wrapper").slimScroll({height:"100%"});

});